package com.uniknow.app.manager;

import java.sql.SQLException;

import com.j256.ormlite.dao.Dao.CreateOrUpdateStatus;
import com.uniknow.app.AppConfig;
import com.uniknow.app.bin.UserBean;

import android.content.Context;


public class UserManager extends BaseManager<UserBean>{
	private static UserManager instance = null; 
	public static UserBean userBean;
	
	public UserManager(Context context, Class<UserBean> clazz) {
		super(context, clazz);
	}
	
	public static UserManager getManager(Context context){
		if(instance==null){
			instance = new UserManager(context,UserBean.class);
		}
		return instance;
	}
	
	@Override
	public int add(Object o) {
		CreateOrUpdateStatus msg = null;
		try {
			msg = dao.createOrUpdate((UserBean) o);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return msg.getNumLinesChanged();
	}

	/**
	 * 初始化User对象
	 */
	public void init(){
		if(AppConfig.DeBug){
			userBean = new UserBean();
			userBean.setUserid(16);
			userBean.setUserName("123");
			userBean.setPassWord("123");
		}
	}
	

}
